/**
 * 命名管道读端
*/

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#include <unistd.h>


int main(int argc, char **argv)
{
    if (2 > argc)
    {
        fprintf(stderr, "%s <fifo_filename>\n", argv[0]);
        exit(EXIT_FAILURE);
    }

    int fd = open(argv[1], O_RDONLY);
    if (0 > fd)
    {
        perror("open error: ");
        exit(EXIT_FAILURE);
    }

    char buf[1024] = {0};
    read(fd, buf, 1024);

    printf("%s\n", buf);

    close(fd);
    return 0;
}